package com.cdn.plugin.console;

import com.intellij.execution.filters.ConsoleFilterProvider;
import com.intellij.execution.filters.Filter;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
import org.jetbrains.annotations.NotNull;

import java.util.Objects;

/**
 */
public class MyBatisLogConsoleFilterProvider implements ConsoleFilterProvider {
    private final Key<ConsoleFilter> key = Key.create(ConsoleFilter.class.getName());

    public MyBatisLogConsoleFilterProvider() {

    }

    @Override
    public Filter @NotNull [] getDefaultFilters(@NotNull Project project) {
        ConsoleFilter filter = project.getUserData(key);
        if (Objects.isNull(filter)) {
            filter = new ConsoleFilter();
            project.putUserData(key, filter);
        }
        return new Filter[] { filter };
    }
}
